﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Create_Image.ascx.vb"
    Inherits="Control_Contents_Create_Image" %>
<script type="text/javascript" language="javascript">
    function ConvertText() {
        alert("start");
        txtTitle = document.getElementById("<%= txtTitle.ClientID %>");
        var str = txtTitle.value.trim();
        txtTitle.value = str.substring(0, 1) + str.substring(1, str.length).toLowerCase();
        return false;
    }
    function setID(ID) {
        document.getElementById('<%=rowID.ClientID %>').value = ID;
    }
    function Change_Assign() {
        var chkIsHot = document.getElementById("<%=chkIsHot.ClientID %>");
        if (chkIsHot.checked == true) {
            $('#imageBig').show();
            ValidatorEnable(document.getElementById("<%=regImageBig.ClientID %>"), true);
        } else {
            $('#imageBig').hide();
            ValidatorEnable(document.getElementById("<%=regImageBig.ClientID %>"), false);
        }
    }
    function ajaxJquery() {        
        $(document).ready(function () {
            $(".ItemDisabled").attr("disabled", "true");
            Change_Assign();
            //Upload Image
            $('#file_upload').uploadify({
                'uploader': '<%=ResolveUrl("~/uploadify/uploadify.swf")%>',
                'script': '<%=ResolveUrl("~/uploadify/Upload.ashx?folder=ImageStorage")%>',
                'cancelImg': '<%=ResolveUrl("~/uploadify/cancel.png")%>',
                'folder': '<%=ResolveUrl("~/Uploads")%>',
                'auto': false,
                'multi': false,
                'fileExt': '*.jpg;*.gif;*.png;*.jpeg;*.bmp',
                'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG , .JPEG , .BMP)',
                'fileDataName': 'myfile',
                'sizeLimit': '<%= ConfigurationManager.AppSettings("maxupload") %>',
                'onComplete': function (event, ID, fileObj, response, data) {
                    $('#<%=hidImagePath.ClientID %>').val('<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response);
                    $('#<%=imgUpload.ClientID %>').attr("src", '<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response);
                }
            });

//            //Upload Image Slider
//            $('#fileAlbum').uploadify({
//                'uploader': '<%=ResolveUrl("~/uploadify/uploadify.swf")%>',
//                'script': '<%=ResolveUrl("~/uploadify/Upload.ashx?folder=ImageStorage")%>',
//                'cancelImg': '<%=ResolveUrl("~/uploadify/cancel.png")%>',
//                'folder': '<%=ResolveUrl("~/Uploads")%>',
//                'auto': false,
//                'multi': false,
//                'fileExt': '*.jpg;*.gif;*.png;*.jpeg;*.bmp',
//                'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG , .JPEG , .BMP)',
//                'fileDataName': 'myfile',
//                'sizeLimit': '<%= ConfigurationManager.AppSettings("maxupload") %>',
//                'onComplete': function (event, ID, fileObj, response, data) {
//                    $('#<%=hidImageBig.ClientID %>').val('<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response);
//                    $('#<%=imagebig.ClientID %>').attr("src", '<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response);
//                }
//            });

            var str = "";
            //Upload Album 
            $('#fileAlbum').uploadify({

                'uploader': '<%=ResolveUrl("~/uploadify/uploadify.swf")%>',
                'script': '<%=ResolveUrl("~/uploadify/UploadAlbum.ashx?folder=ImageStorage")%>',
                'cancelImg': '<%=ResolveUrl("~/uploadify/cancel.png")%>',
                'folder': '<%=ResolveUrl("~/Uploads")%>',
                'auto': false,
                'multi': true,
                'fileExt': '*.jpg;*.gif;*.png;*.jpeg;*.bmp',
                'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG , .JPEG , .BMP)',
                'fileDataName': 'fileAlbum',
                'sizeLimit': '<%= ConfigurationManager.AppSettings("maxupload") %>',
                'onComplete': function (event, ID, fileObj, response, data) {
                    str += '<%= ConfigurationManager.AppSettings("ImageDomain") %>' + response;
                },
                'onAllComplete': function (event, data) {
                    str += "0";
                    var myAlbum = new Array();
                    myAlbum = str.split(",");
                    str = "";
                    for (var i = 0; i < myAlbum.length - 1; i++) {
                        var index = 0;
                        index = Math.floor(Math.random() * 100);
                        $(".GridBorder").append("<tr id='" + index + "' ><td Width='10%' class='text_list_links' align='center' > <a  class='delbutton' style='cursor:pointer;' onclick='RemoveRow(" + index + ");' > Xóa </a> </td> <td Width='20%' class='text_list_links' align='left' > <img alt=''   src='" + myAlbum[i] + "' Style='width: 100px; height: 68px; top: 0px; left: 0px;' class='ag-Jd-Pd' /> </td><td Width='20%' class='text_list_links' align='left' ><textarea id='TextArea1' cols='10' rows='4'></textarea></td></tr>");

                    }
                }
            });
        });
    }
    function RemoveRow(i) {
        $(".GridBorder #" + i).remove();

    }
    function getAllImages() {

        var strImage = "";
        var strComment = "";
        $(".GridBorder tr td img").each(function (e) {
            strImage += $(this).attr("src") + ","
        });
        $(".GridBorder tr td textarea").each(function (e) {
            strComment += $(this).val() + ";"
        });
        $("#<%=hidStrImage.ClientID()%>").val(strImage + '0');
        $("#<%=hidStrCommnet.ClientID()%>").val(strComment + '0');
    }

    function setKeyWordValue(value, sListId) {
        $("#<%=txtKeyword.ClientID()%>").val(sListId);
        $("#<%=txtStrKeyWord.ClientID()%>").val(value);
        removeAllOption('selKeyWord');
        appendOptionLast(sListId, value, 'selKeyWord');

    }
    function getKeywordValue() {
        return $("#<%=txtKeyword.ClientID()%>").val();
    }
    function settxtSubjectValue(value, id) {
        $("#<%=txtSubject.ClientID()%>").val(value);
        $("#<%=txtSubjectId.ClientID()%>").val(id);
    }
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="BoxField">
            <div class="DivRow">
                <div class="DivLabel">
                    <h3>
                        THÊM NỘI DUNG ALBUM
                    </h3>
                </div>
                <div class="lblEdit">
                    <span class="fieldRequired">&nbsp;</span>Trường yêu cầu nhập dữ liệu<%--<textarea vi id="TextArea1"
                        cols="20"  rows="2"></textarea>--%></div>
                <div class="Error">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="#FF3300" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblTitle" CssClass="Tiêu đề" runat="server" Text="Tiêu đề:" /><span
                        class="fieldRequired">&nbsp;</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
                        Display="None" ErrorMessage=" Vui lòng nhập tiêu đề bản tin."></asp:RequiredFieldValidator>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtTitle" CssClass="TextBox" runat="server" Text="" Width="460px" />
                    <asp:LinkButton ID="lnkConvertText" Text="convert text" CausesValidation="false"
                        OnClientClick="return ConvertText();" runat="server"></asp:LinkButton>
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblDescription" CssClass="TextLabel" runat="server" Text="Mô tả:" />
                    <span class="fieldRequired">&nbsp;</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtDescription"
                        Display="None" ErrorMessage="Vui lòng nhập mô tả bản tin."></asp:RequiredFieldValidator>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtDescription" CssClass="TextBox" runat="server" Text="" Width="460px"
                        Height="100px" Rows="5" TextMode="MultiLine" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label1" CssClass="TextLabel" runat="server" Text="Ảnh bài viết:" />
                    <span class="fieldRequired">&nbsp;</span>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="hidImagePath"
                        Display="None" ErrorMessage="Vui lòng chọn ảnh đại diện."></asp:RequiredFieldValidator>
                </div>
                <div class="DivTextBox">
                    <input id="file_upload" name="file_upload" type="file" />
                    <a href="javascript:$('#file_upload').uploadifyUpload();">Upload Files</a>
                </div>
            </div>
            <div style="height: 100px;">
                <asp:Image ID="imgUpload" runat="server" BorderWidth="0px" Height="100px" Width="100px"
                    ImageUrl="~/Images/NoPhotoAvailable.jpg" />
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label3" CssClass="TextLabel" runat="server" Text="Thêm ảnh vào Album:" />
                    <span class="fieldRequired"></span>
                </div>
                <div class="DivTextBox">
                    <input id="fileAlbum" name="file_upload" type="file" />
                    <a href="javascript:$('#fileAlbum').uploadifyUpload();">Upload Files</a>
                </div>
            </div>
            <div style="width: 100%;" class="DivTextBox">
                <table runat="server" cellpadding="0" width="50%" cellspacing="0" border="1" class="GridBorder">
                    <tr>
                        <td width='10%' class='text_list_links' align='center'>
                        </td>
                        <td width='20%' class='text_list_links' align='left'>
                            Ảnh
                        </td>
                        <td width='20%' class='text_list_links' align='left'>
                            Mô tả
                        </td>
                    </tr>
                </table>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label2" CssClass="TextLabel" runat="server" Text="Tác giả:" />
                    <span class="fieldRequired">&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
                        runat="server" ControlToValidate="txtAuthor" Display="None" ErrorMessage="Vui lòng nhập tác giả."></asp:RequiredFieldValidator>
                    </span>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtAuthor" CssClass="TextBox" Text="" runat="server"></asp:TextBox>
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label4" CssClass="TextLabel" runat="server" Text="Là tin nóng:" />
                    <asp:CheckBox ID="chkIsHot" onclick="Change_Assign();" runat="server" />
                </div>
            </div>
            <div id="imageBig" style="display: none" class="DivRow">
                <div class="DivRow">
                    <div class="DivLabel">
                        <asp:Label ID="Label8" CssClass="TextLabel" runat="server" Text="Ảnh Bigbaner:" />
                        <span class="fieldRequired">&nbsp;</span>
                        <asp:RequiredFieldValidator ID="regImageBig" runat="server" ControlToValidate="hidImageBig"
                            Display="None" ErrorMessage="Vui lòng chọn ảnh Bigbaner."></asp:RequiredFieldValidator>
                    </div>
                    <div class="DivTextBox">
                        <input id="file_big" name="file_big" type="file" />
                        <a href="javascript:$('#file_big').uploadifyUpload();">Upload Files</a>
                    </div>
                </div>
                <div style="height: 100px;">
                    <asp:Image ID="imagebig" runat="server" BorderWidth="0px" Height="100px" Width="100px"
                        ImageUrl="~/Images/NoPhotoAvailable.jpg" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label5" CssClass="TextLabel" runat="server" Text="SSM Original:" />
                    <asp:CheckBox ID="chkIsNew" runat="server" />
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="lblMenu_property" CssClass="TextLabel" runat="server" Text="Nhánh tin:" />
                    <span class="fieldRequired">&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
                        runat="server" ControlToValidate="drlMenu" Display="None" ErrorMessage="Vui lòng chọn nhánh tin."
                        InitialValue="0"></asp:RequiredFieldValidator>
                    </span>
                </div>
                <div class="DivTextBox">
                    <asp:DropDownList ID="drlMenu" runat="server" Height="20px" CssClass="TextBox">
                    </asp:DropDownList>
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label6" CssClass="TextLabel" runat="server" Text="Chủ đề:" />
                    <span class="fieldRequired">&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
                        runat="server" ControlToValidate="txtSubject" Display="None" ErrorMessage="Vui lòng chọn chủ đề."></asp:RequiredFieldValidator>
                    </span>
                </div>
                <div class="DivTextBox">
                    <asp:TextBox ID="txtSubject" CssClass="TextBox" Enabled="false" Text="" runat="server"></asp:TextBox>&nbsp;<asp:HyperLink
                        ID="hplSelSubject" runat="server" CssClass="btn">Chọn</asp:HyperLink>
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    <asp:Label ID="Label7" CssClass="TextLabel" runat="server" Text="Từ khóa:" />
                    <span class="fieldRequired">&nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator7"
                        runat="server" ControlToValidate="txtKeyword" Display="None" ErrorMessage="Vui lòng nhập từ khóa."></asp:RequiredFieldValidator>
                    </span>
                </div>
                <div class="DivTextBox">
                    <select multiple="multiple" id="selKeyWord" style="width: 250px; height: 100px" class="TextBox">
                    </select>
                    &nbsp;<asp:HyperLink ID="hplSelKeyWord" runat="server" CssClass="btn">Chọn</asp:HyperLink>
                </div>
            </div>
            <div class="DivRow">
                <div class="DivLabel">
                    &nbsp;&nbsp;&nbsp;</div>
                <div class="DivTextBox">
                    <asp:Button ID="btnSave" OnClientClick="getAllImages();" runat="server" Text=" Lưu "
                        CssClass="btn" />
                    &nbsp;<asp:Button ID="btnHuy" CausesValidation="false" runat="server" Text=" Hủy "
                        CssClass="btn" />
                </div>
            </div>
        </div>
        <div style="display: none">
            <asp:HiddenField ID="hidID" Value="0" runat="server" />
            <asp:TextBox ID="hidImagePath" Text="" runat="server" />
            <asp:HiddenField ID="hidType" Value="0" runat="server" />
            <asp:HiddenField ID="rowID" Value="0" runat="server" />
            <asp:TextBox ID="hidStrImage" Text="" runat="server" />
            <asp:TextBox ID="hidStrCommnet" Text="" runat="server" />
            <asp:TextBox ID="txtKeyword" CssClass="TextBox" Text="" runat="server" Visible="true"></asp:TextBox>
            <asp:TextBox ID="txtStrKeyWord" CssClass="TextBox" Text="" runat="server" Visible="true"></asp:TextBox>
            <asp:TextBox ID="txtSubjectId" CssClass="TextBox" Text="0" runat="server"></asp:TextBox>
            <asp:TextBox ID="hidImageBig" Text="" runat="server" />
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
